package com.example.nettydemo.service.impl;

import com.example.nettydemo.dto.mock.User;
import com.example.nettydemo.service.UserService;
import com.example.nettydemo.util.MockData;
import org.springframework.stereotype.Service;

/**
 * @author WZW
 * @date 2020/5/9
 */
@Service
public class UserServiceImpl implements UserService {

    /*@Autowired
    private UserMapper userMapper;*/

    @Override
    public User getOneByGuid(String guid) {
//        return userMapper.selectOne(Wrappers.<User>lambdaQuery().eq(User::getGuid, guid));
        return MockData.USER_LIST.stream()
                .filter(user -> user.getGuid().equals(guid))
                .findFirst()
                .orElseGet(() -> User.builder().guid(guid).username("user-" + guid).balance(1000).build());
    }
}
